<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" />
    <title>申请企业</title>
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/weui.min.css')}}">
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/jquery-weui.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/iconfont.css')}}">
    @if($skinid == 3)
        <link rel="stylesheet" href="/css/system/common.css">
        <link rel="stylesheet" href="/css/system/apply-company.css">
        <link rel="stylesheet" href="/css/system/set-up.css">
    @else
        <link rel="stylesheet" href="/css/system/common.css">
        <link rel="stylesheet" href="/css/theme-blue/system/apply-company.css">
        <link rel="stylesheet" href="/css/theme-blue/system/set-up.css">
    @endif

    @include('sysadmin.head')
</head>
<body ontouchstart>
<div class="mian-container">
    <div class="colleague-verifice">
        <div class="confirm-bk">
            <div class="weui-search-bar" id="searchBar">
                <form class="weui-search-bar__form">
                    <div class="weui-search-bar__box">
                        <i class="weui-icon-search"></i>
                        <input type="search" class="weui-search-bar__input" id="searchInput" name="name" placeholder="输入企业名称搜索企业" required="">
                        <a href="javascript:" class="weui-icon-clear" id="searchClear"></a>
                    </div>
                    <label class="weui-search-bar__label" id="searchText">
                        <i class="weui-icon-search"></i>
                        <span>搜索</span>
                    </label>
                </form>
                <a href="javascript:" class="weui-search-bar__cancel-btn" id="searchCancel">搜索</a>
            </div>
        </div>
        <div class="weui-cells">
            @if(isset($company))
                @foreach($company as $c)
                    <div class="weui-cell">
                        <div class="weui-cell__hd"><img src='{{"/uploads/images/company-logo/".$c->corpid.".png"}}'></div>
                        <div class="weui-cell__bd">
                            <p class="mar-bottom">{{$c->name}}<a href="javascript:void(0)" class="a-btn pass-btn apply-com" data-id="{{$c->id}}">申请加入</a></p>
                            <p class="gray-color">{{$c->slogan}}</p>
                        </div>
                    </div>
                @endforeach
            @endif
        </div>
        {!! csrf_field() !!}
    </div>
    <div class="shadow-hidden"></div>
    <div class="hidden-sec">
        <div class="popup"><h3>附言</h3><i class="weui-icon-cancel"></i></div>
        <form method="post" action="" onsubmit="return false;">
            <input type="text" value="" name="quote">
            <input type="hidden" value="" name="comid">
            <button type="submit" class="sub-mit apply-com-yes">申请</button>
        </form>
    </div>
</div>
<script src="{{asset('/kaohe/js/jquery-2.1.4.min.js')}}"></script>
<script src="{{asset('/addons/jquery-weui-build/js/fastclick.js')}}"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>
<script src="{{asset('/addons/jquery-weui-build/js/jquery-weui.min.js')}}"></script>
<script>
    $(document).ready(function () {
        $('.apply-com-yes').click(function () {
            $('.apply-com-yes').attr('disabled','disabled');
            setInterval(function(){
                $('.apply-com-yes').attr('disabled',false);
            },3000);
            var comid = $('input[name=comid]').val();
            var token = $('input[name=_token]').val();
            var quote = $('input[name=quote]').val().trim();
            if(quote==''){
                $.toast("请输入附言",'text');
                return false;
            }
            $.ajax({
                url:'/front/join-company?_token='+token,
                type:'post',
                dataType:'json',
                data:{'comid':comid,'quote':quote},
                error: function (request) {
                    $.toast('网络错误',"text");
                },
                success: function (data) {
                    if (data.status == 'success') {
                        $.toast(data.msg);
                        setTimeout(function(){ window.location.href=data.redirectUrl; }, 1000);
                    } else {
                        $.toast(data.msg,"text");
                    }
                },
            });
        })
    });
    $('.apply-com').click(function () {
        var comid = $(this).attr('data-id');
        $('input[name=comid]').val(comid);
        $('.shadow-hidden').css('display','block');
        $('.hidden-sec').css('display','block');
    })
    $('.hidden-sec .popup i').click(function () {
        $('.hidden-sec').css('display','none');
        $('.shadow-hidden').css('display','none');
    })
    $('#searchCancel').click(function () {
        $('.weui-search-bar__form').submit();
    })
</script>
</body>
</html>